#!/bin/bash
file_name=functions.sh
funcs=`which $file_name`
if [ "$funcs" != "" ] ;then
  echo "funcs=$funcs"
  . $funcs
else
  funcs=`dirname $0`/$file_name
  echo "$PWD"
  echo "funcs=$funcs"
  if [ "$funcs" != "" ] ;then
    . $funcs
  else
    exit
  fi
fi

lfs_packages_dir_urls_list1="
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/6.3/
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/6.4/
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/7.0/
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/7.1/"

lfs_packages_tar_urls_list2="
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-6.3.tar
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-6.4.tar
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-7.0.tar
http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-7.1.tar"


files_list_63="
autoconf-2.61.tar.bz2
automake-1.10.tar.bz2
bash-3.2-fixes-5.patch
bash-3.2.tar.gz
bash-doc-3.2.tar.gz
binutils-2.17.tar.bz2
bison-2.3.tar.bz2
bzip2-1.0.4-install_docs-1.patch
bzip2-1.0.4.tar.gz
coreutils-6.9-i18n-1.patch
coreutils-6.9-suppress_uptime_kill_su-1.patch
coreutils-6.9-uname-1.patch
coreutils-6.9.tar.bz2
db-4.5.20-fixes-1.patch
db-4.5.20.tar.gz
dejagnu-1.4.4.tar.gz
diffutils-2.8.1-i18n-1.patch
diffutils-2.8.1.tar.gz
e2fsprogs-1.40.2.tar.gz
expect-5.43.0-spawn-1.patch
expect-5.43.0.tar.gz
file-4.21.tar.gz
findutils-4.2.31.tar.gz
flex-2.5.33.tar.bz2
gawk-3.1.5-segfault_fix-1.patch
gawk-3.1.5.tar.bz2
gcc-4.1.2-specs-1.patch
gcc-4.1.2.tar.bz2
gettext-0.16.1.tar.gz
glibc-2.5.1.tar.bz2
glibc-libidn-2.5.1.tar.gz
grep-2.5.1a-redhat_fixes-2.patch
grep-2.5.1a.tar.bz2
groff-1.18.1.4-debian_fixes-1.patch
groff-1.18.1.4.tar.gz
grub-0.97-disk_geometry-1.patch
grub-0.97.tar.gz
gzip-1.3.12.tar.gz
iana-etc-2.20.tar.bz2
inetutils-1.5-no_server_man_pages-2.patch
inetutils-1.5.tar.gz
iproute2-2.6.20-070313.tar.gz
kbd-1.12-backspace-1.patch
kbd-1.12-gcc4_fixes-1.patch
kbd-1.12.tar.bz2
less-406.tar.gz
lfs-bootscripts-6.3.tar.bz2
libtool-1.5.24.tar.gz
linux-2.6.22.5.tar.bz2
m4-1.4.10.tar.bz2
make-3.81.tar.bz2
man-db-2.4.4-fixes-1.patch
man-db-2.4.4.tar.gz
man-pages-2.63.tar.bz2
mktemp-1.5-add_tempfile-3.patch
mktemp-1.5.tar.gz
module-init-tools-3.2.2-modprobe-1.patch
module-init-tools-3.2.2.tar.bz2
ncurses-5.6-coverity_fixes-1.patch
ncurses-5.6.tar.gz
patch-2.5.4.tar.gz
perl-5.8.8-libc-2.patch
perl-5.8.8.tar.bz2
procps-3.2.7.tar.gz
psmisc-22.5.tar.gz
readline-5.2-fixes-3.patch
readline-5.2.tar.gz
sed-4.1.5.tar.gz
shadow-4.0.18.1-useradd_fix-2.patch
shadow-4.0.18.1.tar.bz2
sysklogd-1.4.1-8bit-1.patch
sysklogd-1.4.1-fixes-2.patch
sysklogd-1.4.1.tar.gz
sysvinit-2.86.tar.gz
tar-1.18.tar.bz2
tcl8.4.15-src.tar.gz
texinfo-4.9-multibyte-1.patch
texinfo-4.9-tempfile_fix-1.patch
texinfo-4.9.tar.bz2
udev-113.tar.bz2
udev-config-6.3.tar.bz2
util-linux-2.12r-cramfs-1.patch
util-linux-2.12r-lseek-1.patch
util-linux-2.12r.tar.bz2
vim-7.1-fixes-1.patch
vim-7.1-lang.tar.gz
vim-7.1-mandir-1.patch
vim-7.1.tar.bz2
zlib-1.2.3.tar.gz"

files_list_64="
autoconf-2.63.tar.bz2
automake-1.10.1-test_fix-1.patch
automake-1.10.1.tar.bz2
bash-3.2-fixes-8.patch
bash-3.2.tar.gz
bash-doc-3.2.tar.gz
binutils-2.18-GCC43-1.patch
binutils-2.18-configure-1.patch
binutils-2.18.tar.bz2
bison-2.3.tar.bz2
bzip2-1.0.5-install_docs-1.patch
bzip2-1.0.5.tar.gz
coreutils-6.12-i18n-2.patch
coreutils-6.12-old_build_kernel-1.patch
coreutils-6.12-uname-1.patch
coreutils-6.12.tar.gz
db-4.7.25-upstream_fixes-1.patch
db-4.7.25.tar.gz
dejagnu-1.4.4.tar.gz
diffutils-2.8.1-i18n-1.patch
diffutils-2.8.1.tar.gz
e2fsprogs-1.41.3.tar.gz
expect-5.43.0-spawn-1.patch
expect-5.43.0-tcl_8.5.5_fix-1.patch
expect-5.43.0.tar.gz
file-4.26.tar.gz
findutils-4.4.0.tar.gz
flex-2.5.35.tar.bz2
gawk-3.1.6.tar.bz2
gcc-4.3.2.tar.bz2
gettext-0.17.tar.gz
glibc-2.8-20080929-iconv_tests-1.patch
glibc-2.8-20080929-ildoubl_test-1.patch
glibc-2.8-20080929.tar.bz2
gmp-4.2.4.tar.bz2
grep-2.5.3-debian_fixes-1.patch
grep-2.5.3-upstream_fixes-1.patch
grep-2.5.3.tar.bz2
groff-1.18.1.4-debian_fixes-1.patch
groff-1.18.1.4.tar.gz
grub-0.97-256byte_inode-1.patch
grub-0.97-disk_geometry-1.patch
grub-0.97.tar.gz
gzip-1.3.12.tar.gz
iana-etc-2.30.tar.bz2
inetutils-1.5-no_server_man_pages-2.patch
inetutils-1.5.tar.gz
iproute2-2.6.26.tar.bz2
kbd-1.14.1-backspace-1.patch
kbd-1.14.1.tar.gz
less-418.tar.gz
lfs-bootscripts-20081031.tar.bz2
libtool-2.2.6a.tar.gz
linux-2.6.27.4.tar.bz2
m4-1.4.12.tar.bz2
make-3.81.tar.bz2
man-db-2.5.2.tar.gz
man-pages-3.11.tar.bz2
module-init-tools-3.4.1-manpages-1.patch
module-init-tools-3.4.1.tar.bz2
mpfr-2.3.2.tar.bz2
ncurses-5.6-coverity_fixes-1.patch
ncurses-5.6.tar.gz
patch-2.5.4.tar.gz
perl-5.10.0-consolidated-1.patch
perl-5.10.0.tar.gz
procps-3.2.7-watch_unicode-1.patch
procps-3.2.7.tar.gz
psmisc-22.6.tar.gz
readline-5.2-fixes-5.patch
readline-5.2.tar.gz
sed-4.1.5.tar.gz
shadow-4.1.2.1.tar.bz2
sysklogd-1.5.tar.gz
sysvinit-2.86.tar.gz
tar-1.20.tar.bz2
tcl8.5.5-src.tar.gz
texinfo-4.13a.tar.gz
udev-130.tar.bz2
udev-config-20081015.tar.bz2
util-linux-ng-2.14.1.tar.bz2
vim-7.2-fixes-3.patch
vim-7.2-lang.tar.gz
vim-7.2.tar.bz2
zlib-1.2.3.tar.bz2"

files_list_70="
autoconf-2.68.tar.bz2
automake-1.11.1.tar.bz2
bash-4.2-fixes-3.patch
bash-4.2.tar.gz
binutils-2.21.1a.tar.bz2
bison-2.5.tar.bz2
bzip2-1.0.6-install_docs-1.patch
bzip2-1.0.6.tar.gz
check-0.9.8.tar.gz
check.sh
coreutils-8.14-i18n-1.patch
coreutils-8.14-uname-1.patch
coreutils-8.14.tar.xz
dejagnu-1.5.tar.gz
diffutils-3.2.tar.gz
e2fsprogs-1.41.14.tar.gz
expect5.45.tar.gz
extra.sh
file-5.09.tar.gz
findutils-4.4.2.tar.gz
flex-2.5.35-gcc44-1.patch
flex-2.5.35.tar.bz2
gawk-4.0.0.tar.bz2
gcc-4.6.1-cross_compile-1.patch
gcc-4.6.1-locale-1.patch
gcc-4.6.1-startfiles_fix-1.patch
gcc-4.6.1.tar.bz2
gdbm-1.9.1.tar.gz
gettext-0.18.1.1.tar.gz
glibc-2.14.1-cpuid-1.patch
glibc-2.14.1-fixes-1.patch
glibc-2.14.1-gcc_fix-1.patch
glibc-2.14.1.tar.bz2
gmp-5.0.2.tar.bz2
grep-2.9.tar.gz
groff-1.21.tar.gz
grub-1.99.tar.gz
gzip-1.4.tar.gz
iana-etc-2.30.tar.bz2
inetutils-1.8.tar.gz
iproute2-2.6.39.tar.gz
kbd-1.15.2-backspace-1.patch
kbd-1.15.2.tar.gz
less-444.tar.gz
lfs-bootscripts-20111017.tar.bz2
libpipeline-1.2.0.tar.gz
libtool-2.4.tar.gz
linux-3.1.tar.bz2
m4-1.4.16.tar.bz2
make-3.82.tar.bz2
man-db-2.6.0.2.tar.gz
man-pages-3.35.tar.gz
md5sums
module-init-tools-3.16-man_pages-1.patch
module-init-tools-3.16.tar.bz2
mpc-0.9.tar.gz
mpfr-3.1.0.tar.bz2
ncurses-5.9.tar.gz
patch-2.6.1-test_fix-1.patch
patch-2.6.1.tar.bz2
perl-5.14.2-libc-1.patch
perl-5.14.2.tar.bz2
procps-3.2.8-fix_HZ_errors-1.patch
procps-3.2.8-watch_unicode-1.patch
procps-3.2.8.tar.gz
psmisc-22.14.tar.gz
readline-6.2-fixes-1.patch
readline-6.2.tar.gz
sed-4.2.1.tar.bz2
shadow-4.1.4.3.tar.bz2
sysklogd-1.5.tar.gz
sysvinit-2.88dsf.tar.bz2
tar-1.26.tar.bz2
tcl8.5.10-src.tar.gz
texinfo-4.13a.tar.gz
udev-173-testfiles.tar.bz2
udev-173.tar.bz2
udev-config-20100128.tar.bz2
util-linux-2.20.tar.bz2
vim-7.3.tar.bz2
wget-list
xz-5.0.3.tar.bz2
zlib-1.2.5.tar.bz2"

files_list_71="
autoconf-2.68.tar.bz2
automake-1.11.3.tar.xz
bash-4.2-fixes-4.patch
bash-4.2.tar.gz
binutils-2.22.tar.bz2
bison-2.5.tar.bz2
bzip2-1.0.6-install_docs-1.patch
bzip2-1.0.6.tar.gz
check-0.9.8.tar.gz
check.sh
coreutils-8.15-i18n-1.patch
coreutils-8.15-uname-1.patch
coreutils-8.15.tar.xz
dejagnu-1.5.tar.gz
diffutils-3.2.tar.gz
e2fsprogs-1.42.tar.gz
expect5.45.tar.gz
extra.sh
file-5.10.tar.gz
findutils-4.4.2.tar.gz
flex-2.5.35-gcc44-1.patch
flex-2.5.35.tar.bz2
gawk-4.0.0.tar.bz2
gcc-4.6.2-cross_compile-1.patch
gcc-4.6.2-startfiles_fix-1.patch
gcc-4.6.2.tar.bz2
gdbm-1.10.tar.gz
gettext-0.18.1.1.tar.gz
glibc-2.14.1-cpuid-1.patch
glibc-2.14.1-fixes-1.patch
glibc-2.14.1-gcc_fix-1.patch
glibc-2.14.1-sort-1.patch
glibc-2.14.1.tar.bz2
gmp-5.0.4.tar.xz
grep-2.10.tar.xz
groff-1.21.tar.gz
grub-1.99.tar.gz
gzip-1.4.tar.gz
iana-etc-2.30.tar.bz2
inetutils-1.9.1.tar.gz
iproute2-3.2.0.tar.xz
kbd-1.15.2-backspace-1.patch
kbd-1.15.2.tar.gz
kmod-5.tar.xz
less-444.tar.gz
lfs-bootscripts-20120229.tar.bz2
libpipeline-1.2.0.tar.gz
libtool-2.4.2.tar.gz
linux-3.2.6.tar.xz
m4-1.4.16.tar.bz2
make-3.82.tar.bz2
man-db-2.6.1.tar.gz
man-pages-3.35.tar.gz
md5sums
mpc-0.9.tar.gz
mpfr-3.1.0-fixes-1.patch
mpfr-3.1.0.tar.bz2
ncurses-5.9.tar.gz
patch-2.6.1-test_fix-1.patch
patch-2.6.1.tar.bz2
perl-5.14.2-libc-1.patch
perl-5.14.2-security_fix-1.patch
perl-5.14.2.tar.bz2
procps-3.2.8-fix_HZ_errors-1.patch
procps-3.2.8-watch_unicode-1.patch
procps-3.2.8.tar.gz
psmisc-22.15.tar.gz
readline-6.2-fixes-1.patch
readline-6.2.tar.gz
sed-4.2.1.tar.bz2
shadow-4.1.5-nscd-1.patch
shadow-4.1.5.tar.bz2
sysklogd-1.5.tar.gz
sysvinit-2.88dsf.tar.bz2
tar-1.26.tar.bz2
tcl8.5.11-src.tar.gz
texinfo-4.13a.tar.gz
udev-181.tar.xz
udev-config-20100128.tar.bz2
util-linux-2.20.1.tar.bz2
vim-7.3.tar.bz2
wget-list
xz-5.0.3.tar.bz2
zlib-1.2.6.tar.bz2"

function patch_xxx()
{
  local ac_pkg=$1
  local ac_patch=$2
  if test -d $ac_pkg; then
    if test -f $ac_patch; then
      cd $ac_pkg
      patch -Np1 -i $$ac_patch
      cd -
    fi
  else
    echoTextRed "pkg $ac_pkg not exist!!"
  fi
}

mkdir /tmp/test/ -pv
for f in $files_list_63
do
  touch /tmp/test/$f
done
cd /tmp/test
for f in $files_list_63
do
  echo $f | grep tar | awk -F '-' '{print $1}'
done

exit
ls util-linux-*.tar.*
ls util-linux-*.patch*



